package design_mode.策略模式;

import design_mode.策略模式.打折算法.CashNormal;
import design_mode.策略模式.打折算法.CashRebate;
import design_mode.策略模式.打折算法.CashReturn;
import design_mode.策略模式.打折算法.CashSuper;

public class CashContext {
    // 策略工厂
    private CashSuper result;

    public CashContext(int cashType) {
        switch (cashType) {
            case 1:
                this.result = new CashNormal();
                break;
            case 2:
                this.result = new CashRebate(0.8);
                break;
            case 3:
                this.result = new CashReturn(200, 2);
                break;
        }
    }

    public double getResult(double price, int num) {
        return this.result.acceptCash(price, num);
    }
}
